<template>
	<view class="container">
		<u-navbar :title="title" :border-bottom="false" back-icon-color="#ffffff" title-color="#fff" :background="{backgroundColor:'#000'}"></u-navbar>
		<rich-text type="text" :nodes="nodes"  class="container" style="color: #fff;"></rich-text>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				nodes: '',
				i:0,
				title: '用户协议',
			}
		},
		onLoad(options) {
			this.i = options.i
			if(this.i == 1){
				this.title = '隐私政策'
			}
			this.xieyi()
		},
		onShow() {
			
		},
		methods: {
			xieyi(){
				uni.request({
					url: this.global.url + 'appv1/setting/xieyi',
					method: 'POST',
					header: {
						'content-Type': 'application/x-www-form-urlencoded'
					},
					data: {
						type: this.i
					},
					success: (res) => {
						if(res.data.code == 1){
							this.nodes = this.escapeHtml(res.data.data.contents)
							console.log(this.nodes)
						}
					}
				})
			},
			// 处理方法
			escapeHtml(str) {
				var arrEntities = {
					'lt': '<',
					'gt': '>',
					'nbsp': ' ',
					'amp': '&',
					'quot': '"'
				};
				return str.replace(/&(lt|gt|nbsp|amp|quot);/ig, function(all, t) {
					return arrEntities[t];
				});
			},
		}
	}
</script>

<style>
	page {
		background-color: #0f0d0f;
	}
	.container {
		width: 100%;
		height: 100%;
	}
	
</style>
